<?php
	class BinhLuanSuKienDAO
	{
		public static function ThemBinhLuanSuKien($sk)
		{
			$sql="Insert into binh_luan_su_kien(blsk_ma_su_kien,blsk_username,blsk_noi_dung, blsk_ngay_tao,blsk_tong_so_sao) values('$sk->blsk_ma_su_kien','$sk->blsk_username','$sk->blsk_noi_dung','$sk->blsk_ngay_tao','$sk->blsk_tong_so_sao')";
			 $result = QuerySQL($sql);
			 StopConnection();
			return $result;
		}
		public static function ParseToBinhLuanDTO($row)
		{
			$sk=new BinhLuanSuKienDTO();
			$sk->blsk_ma=$row["blsk_ma"];
			$sk->blsk_ma_su_kien=$row["blsk_ma_su_kien"];
			$sk->blsk_username=$row["blsk_username"];
			$sk->blsk_noi_dung=$row["blsk_noi_dung"];
			$sk->blsk_ngay_tao=$row["blsk_ngay_tao"];
			$sk->blsk_tong_so_sao=$row["blsk_tong_so_sao"];
			$sk->tk_avatar=$row["tk_avatar"];
			return $sk;			
		}
		public static function LayDanhSachBinhLuanTheoMaSK($mask,$start,$end)
		{
			$sql="Select tk.tk_avatar,bl.blsk_ma,bl.blsk_ma_su_kien,bl.blsk_username, bl.blsk_noi_dung, bl.blsk_ngay_tao,bl.blsk_tong_so_sao From binh_luan_su_kien bl,tai_khoan tk Where blsk_ma_su_kien='$mask' and bl.blsk_username=tk.tk_username Limit $start,$end";
			$result = QuerySQL($sql);
			$skDTO=null;
			$i=0;
			while($row = mysql_fetch_array($result))
			{
				$skDTO[$i] = BinhLuanSuKienDAO::ParseToBinhLuanDTO($row);
				$i=$i+1;
			}
			StopConnection();
			return $skDTO;
		}
		public static function DemSoBinhLuan($mask)
		{
			$sql="Select count(*)as soluong From binh_luan_su_kien Where blsk_ma_su_kien='$mask'";
			$result = QuerySQL($sql);
			$skDTO=null;
			while($row = mysql_fetch_array($result))
			{
				$skDTO = $row["soluong"];
			}
			StopConnection();
			return $skDTO;
		}
	}
?>